import 'package:flutter/material.dart';
import 'package:tender_flutter/constant/theme_colors.dart';
import 'package:tender_flutter/utils/screen_adaper.dart';
import 'package:tender_flutter/widgets/base_appbar.dart';

typedef void NavigationSearchCallback(keyword);

class SearchAppBar extends BaseAppBar {
  static String keyword = "";

  SearchAppBar(BuildContext context, {NavigationSearchCallback searchCallback})
      : super(
            context,
            Container(
              alignment: Alignment.centerLeft,
              height: kToolbarHeight / 1.6,
              decoration: new BoxDecoration(
                color: ThemeColors.colorWhite,
                borderRadius: new BorderRadius.all(new Radius.circular(5.0)),
              ),
              padding:
                  EdgeInsets.symmetric(horizontal: ScreenAdapter.width(15)),
              child: TextField(
                textAlign: TextAlign.left,
                maxLines: 1,
                decoration: InputDecoration(
                    focusedBorder: OutlineInputBorder(
                        borderSide:
                            BorderSide(width: 0, color: Colors.transparent)),
                    disabledBorder: OutlineInputBorder(
                        borderSide:
                            BorderSide(width: 0, color: Colors.transparent)),
                    enabledBorder: OutlineInputBorder(
                        borderSide:
                            BorderSide(width: 0, color: Colors.transparent)),
                    border: OutlineInputBorder(
                        borderSide:
                            BorderSide(width: 0, color: Colors.transparent)),
                    contentPadding:
                        EdgeInsets.symmetric(vertical: 0, horizontal: -10),
                    icon: Icon(
                      Icons.search_rounded,
                    ),
                    hintText: "搜索内容"),
                style: TextStyle(
                    fontSize: ScreenAdapter.sp(30),
                    color: ThemeColors.colorType1),
                onChanged: (value) {
                  keyword = value;
                },
              ),
            ),
            backgroundColor: ThemeColors.colorType6,
            brightness: Brightness.dark,
            titleSpacing: 0,
            backColor: ThemeColors.colorWhite,
            actions: [
              Container(
                  width: ScreenAdapter.width(150),
                  child: FlatButton(
                      onPressed: () {
                        searchCallback(keyword);
                      },
                      child: Text("搜索",
                          style: TextStyle(
                              fontSize: ScreenAdapter.sp(32),
                              color: ThemeColors.colorWhite))))
            ]);
}
